// import "../../components/basicTable.less";
// import Toolbar from "@/components/ViewComponents/Toolbar";
import { useTranslation } from "react-i18next";
import { get_selectEmergen } from "@/api/EmergencyDictionary";
import { BasicTable, useTable, BasicColumn, FormSchema } from "@/components/Table";
import { TimeDate } from "@/utils/util";

export default function attendance() {
	const { t } = useTranslation();
	// let btnList = ["print", "end"];
	// 配置table
	const columns: BasicColumn[] = [
		{
			title: t("felix_ui.sq_numb"),
			width: 100,
			// dataIndex: "sq_numb",
			render: (text, record, index) => index * 1 + 1 // 设置序号
		},
		{
			title: t("felix_ui.patient_ID"),
			width: 260,
			dataIndex: "patientId"
		},
		{
			title: t("felix_ui.full_name"),
			dataIndex: "fullName"
		},
		{
			title: t("felix_ui.gender"),
			dataIndex: "gender"
		},
		{
			title: t("felix_ui.birthday"),
			dataIndex: "birthday"
			// render: text => <span>{TimeDate(text)}</span>
		},
		{
			title: t("felix_ui.admission_date"),
			dataIndex: "emgDtime",
			render: text => <span>{TimeDate(text)}</span>
		},
		{
			title: t("felix_ui.beneficiary"),
			dataIndex: "beneficiary"
		},
		{
			title: t("felix_ui.pat_cardno"),
			dataIndex: "patCardno"
		},
		{
			title: t("felix_ui.rx_diagnosis"),
			dataIndex: "rxDiagnosis"
		},
		{
			title: t("felix_ui.doctor"),
			dataIndex: "doctorName"
		}
	];
	const TopFormSchema: FormSchema[] = [
		{
			label: t("felix_ui.patient_ID"),
			field: "patientId",
			component: "Input",
			colProps: { span: 6 }
		},
		{
			label: t("felix_ui.admission_date"),
			field: "dtime",
			component: "DatePicker",
			colProps: { span: 6 }
			// componentProps: {
			// 	showTime: true
			// }
		},
		{
			label: t("felix_ui.department"),
			field: "deptId",
			component: "Input",
			colProps: { span: 6 }
		}
	];
	let util = async () => {
		let arr: any = [];
		await get_selectEmergen({}).then(res => {
			arr = res.list.map((item: any) => {
				return {
					...item,
					...item.patients
				};
			});
		});

		return arr;
	};
	// 配置table
	const [registerTable, { getSelectRows }] = useTable({
		columns,
		title: t("felix_ui.EmergencyStatisticsDisplay"),
		api: util,
		bordered: true,
		pagination: true,
		useSearchForm: true,
		rowSelection: true,
		formConfig: {
			labelWidth: 120,
			schemas: TopFormSchema,
			showActionButtonGroup: true,
			showAdvancedButton: false
		}
	});
	console.log(getSelectRows());
	// const handleSubmitRegistration = async () => {
	// 	console.log(getSelectRows());
	// };
	// const handlerToolbarAction = (key: string) => {
	// 	switch (key) {
	// 		case "print":
	// 			handleSubmitRegistration();
	// 			break;
	// 	}
	// 	console.log("key", key);
	// };
	return (
		<div className="page">
			<BasicTable register={registerTable}></BasicTable>
			{/* <Toolbar action={handlerToolbarAction} btnList={btnList} /> */}
		</div>
	);
}
